PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Try Statements

Scripts don't always work perfectly. When a script is executed, errors can occur in the operating system (for example, when a specified file isn't found), in an application (for example, when you specify an object that doesn't exist), and in the script itself. When an error occurs, AppleScript sends a special message known as an error message. An error message is a message that is returned by an application, AppleScript, or the Mac OS when an error occurs during the handling of a command. An error message can include an error number, which is an integer that identifies the error, an error expression, which is an expression, usually a string, that describes the error, and other information.

A script can include one or more collections of statements called error handlers to handle error messages . Error handlers are contained in compound statements, called Try statements, that define the scope of the error handlers they contain. A Try statement is a two-part compound statement that contains a series of AppleScript statements, followed by an error handler to be invoked if any of those statements causes an error. If an error message occurs and there is no handler for it, script execution stops.

For information on other types of handlers, see Handlers.


© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)